home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / ACGIFREE.ZIP / SAMPLES / X11_EX.CPP < prev   
Encoding:
C/C++ Source or Header  |  1996-08-03  |  1.1 KB  |  37 lines

  1.  
  2. #include "math.h"
  3. #include "a_acgi.h"
  4.  
  5. #define X11EX_HALFAMPLITUDE 50      //a_Half the height
  6. #define X11EX_PERIOD        256     //a_The width must be a multiple of 8
  7. #define X11EX_2PI           6.283   //a_This will force the product to be a double (see below)
  8. #define X11EX_IFREQ         4       //a_# is complete cycles
  9.  
  10. int main()
  11. {
  12.   AXBitmap xbmOut;       //_Object for outputting the X11 bitmap
  13.   ABitMatrix bmCanvas;   //a_The bit canvas
  14.  
  15.   //a_Set the canvas size
  16.   bmCanvas.mSetSize(256, 2* X11EX_HALFAMPLITUDE);
  17.   
  18.   //a_Must clear the canvas
  19.   bmCanvas.mSetPlane(); 
  20.  
  21.   //a_Do my drawing here (your basic sine-wave)
  22.   double dY;
  23.   for (int iX = 0x0; iX < X11EX_PERIOD; iX++)
  24.   {
  25.     dY = X11EX_HALFAMPLITUDE - X11EX_HALFAMPLITUDE * cos((X11EX_2PI * iX * X11EX_IFREQ) / X11EX_PERIOD);
  26.     
  27.     //a_NOTE: [Y-coordinate][X-coordinate]! (C++ array/matrix is this way)
  28.     //a_bmCanvas[a] would return ABitArray in y-coordiante {a}
  29.     //a_Also 0,0 is at the top-left
  30.     bmCanvas[(int)dY][iX] = 0x1;    
  31.   }
  32.  
  33.   xbmOut.mimeXBitmap();
  34.   xbmOut.xbmDoBitmap(bmCanvas);
  35.  
  36.   return 0x1;
  37. }